﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DataModel.Models
{
    public partial class Group
    {
        /// <summary>
        /// if Current date &lt Leave date throw Exeption with message &quot Current group end study &quot 
        /// </summary>
        /// <returns>Current study semester</returns>
        /// 
        public int GetCurrentSemester()
        {
            DateTime currentDate = DateTime.Now;
            if (DateTime.Now > this.entranceDate.AddYears(this.amountYears))
            {
                throw new Exception("Current group end study");
            }

            return (currentDate.Month > 8) ? ((currentDate.Year - entranceDate.Year) * 2 + 1) 
                   :(currentDate.Year - entranceDate.Year) * 2;
        }
    }
}
